﻿using System;
using System.Collections.Generic;
using VisionCloud.Core.Model.Sys;
using VisionCloud.Domain.Common;
using VisionCloud.Domain.DtoModel.Ms;
using static VisionCloud.Core.Model.Sys.SysUser;

namespace VisionCloud.Domain.DtoModel.Sys
{
    public class SysUserListDto : SysBaseDto
    {
        public Guid YunUserGuid { get; set; }

        public string Name { get; set; }
        public string PhoneNumber { get; set; }

        public string Email { get; set; }

        public bool IsLock { get; set; }

        /// <summary>
        /// 用户创建时间
        /// </summary>
        public DateTime CreatedDate { get; set; }

        public DateTime LastUpdatedDate { get; set; }

        public SysUser.EnumUserStatus? Status { get; set; }

        public string Position { get; set; }
        public string Department { get; set; }
        public EnumUserGender? Gender { get; set; }
        public string AccountNumber { get; set; }

        public EnumUserType? UserType { get; set; }

        public bool? IsManualMeasureMan { get; set; }

        public List<ProjectInfoDto> Projects { get; set; }

        public string RoleNameList { get; set; }
        public string SysOrgId { get; set; }
    }

    public class USBKeyNODto
    {
        public string USBKeyNO { get; set; }
    }

    public class UserChangeDto
    {
        public Guid YunUserGuid { get; set; }
        public DateTime SurfaceUserUpdateTime { get; set; }
    }

    public class SysUserDto : SysBaseDto
    {
        public Guid UserId { get; set; }
        public Guid YunUserGuid { get; set; }
        public string Code { get; set; }

        public string NewUserCode { get; set; }

        public string Password { get; set; }

        public string Name { get; set; }
        public string PhoneNumber { get; set; }

        public string Email { get; set; }

        public bool IsLock { get; set; }
        public bool IsDelete { get; set; }

        public DateTime LastUpdatedDate { get; set; }

        public SysUser.EnumUserStatus? Status { get; set; }

        public bool IsSuperAdministrator { get; set; }

        public IList<string> RoleNameList { get; set; } = new List<string> { };

        /// <summary>
        /// 角色列表
        /// </summary>
        public IList<Guid> RoleList { get; set; } = new List<Guid> { };

        /// <summary>
        /// 角色代码
        /// </summary>
        public IList<string> RoleCodeList { get; set; } = new List<String>();

        public List<SysOrg> SysOrgs { get; set; } = new List<SysOrg>();

        public List<string> SysOrgIds { get; set; }
        public List<string> SysOrgCodes { get; set; }
        public List<Guid> ProjectIds { get; set; }
        public List<Guid> DeviceIds { get; set; }

        public string Position { get; set; }
        public string Department { get; set; }
        public EnumUserGender? Gender { get; set; }

        public string AccountNumber { get; set; }
        public Guid? AvatarId { get; set; }

        /// <summary>
        /// yunuserid,同步报表时用到
        /// </summary>
        public string RegisterId { get; set; }

        public EnumUserType? UserType { get; set; }

        public bool? IsManualMeasureMan { get; set; }

        /// <summary>
        /// 用户角色
        /// </summary>
        public List<string> Roles { get; set; }

        public bool IsPasswordNeedToChange { get; set; }

        public string IP { get; set; }
        public string OrgId { get; set; }
        public string OrgCode { get; set; }
        public string SysOrgId { get; set; }

        /// <summary>
        /// 公司名称
        /// </summary>
        public string Company { get; set; }

        /// <summary>
        /// 客户端类型
        /// </summary>
        public TokenTypeEnum TokenType { get; set; } = TokenTypeEnum.Web;

        /// <summary>
        /// 是否启动机器人任务，只有true才启动
        /// </summary>
        public bool? EnabledRobotTask { get; set; }

        /// <summary>
        /// 启动机器人任务的最低版本
        /// </summary>
        public string RobotTaskMinimumVersion { get; set; }

        /// <summary>
        /// 建模权限(兼容旧版本没有建模功能)
        /// </summary>
        public bool EnabledModeling { get; set; } = false;

        /// <summary>
        /// 是否开启外立面权限
        /// </summary>
        public bool EnabledExternalWall { get; set; }

        /// <summary>
        /// 开启小程序采集权限0：未授权；1：已授权
        /// </summary>
        public bool EnabledAppletCollecting { get; set; }
    }

    public class UserInfo
    {
        public Guid ProjectId { get; set; }

        public Guid UserId { get; set; }

        public string Name { get; set; }
        public string Phone { get; set; }

        public string Position { get; set; }
        public string Email { get; set; }

        public string Department { get; set; }

        public string RoleName { get; set; }
    }

    /// <summary>
    /// 查询条件对象
    /// </summary>
    public class SysUserCondition : PageBase
    {
        public Guid UserId { get; set; }
        public EnumUserType? UserType { get; set; }
        public List<Guid> ProjectIds { get; set; }
        public string UserName { get; set; }
        public string UserCode { get; set; }
        public string UserEmail { get; set; }
        public string UserPwd { get; set; }

        public string Content { get; set; }

        public bool? IsSuperAdministrator { get; set; }

        /// <summary>
        /// 项目ID
        /// </summary>
        public Guid ProjectId { get; set; }

        public string RoleName { get; set; }

        public EnumUserStatus? Status { get; set; }

        public string Department { get; set; }

        public Guid CompanyGuid { get; set; }
    }

    public class SysUserPageDto : PageBase
    {
        /// <summary>
        /// 查询
        /// </summary>
        //public String Query { get; set; }

        public String AppId { get; set; }
    }

    public class SysSearchResp
    {
        public List<SysUser> users { get; set; }

        public Boolean isEnd { get; set; }
    }

    public class ResetDto
    {
        public string NewPassword { get; set; }

        public string OldPassword { get; set; }

        /// <summary>
        /// 接收验证码的账号：手机号或邮箱
        /// </summary>
        public string VerifyAccount { set; get; }

        public string VerifyCode { set; get; }
    }

    public class RegisterDto
    {
        public string IP { get; set; }
        public string PhoneNumber { get; set; }

        public string OldEmail { get; set; }
        private string _email;

        public string Email
        {
            get
            {
                return
                    _email.ToLower();
            }
            set
            {
                _email = !string.IsNullOrWhiteSpace(value) ? value.ToLower() : string.Empty;
            }
        }

        /// <summary>
        /// 操作类型 0：激活设备 1：更改邮箱 2：更改电话 3: 重置密码
        /// </summary>
        public int OperationType { get; set; }

        /// <summary>
        /// 0:email 1:phone
        /// </summary>
        public int AccountType { get; set; }

        public string Account { get => AccountType == 0 ? Email : PhoneNumber; }

        public string DeviceNumber { get; set; }

        public string EncryptedDogNumber { get; set; }

        public string VerifyCode { get; set; }

        public string EncryptedDogType { get; set; }

        public string Password { get; set; }

        public List<Guid> ProjectGuids { get; set; }

        public Guid YunUserGuid { get; set; }

        public bool? IsManualMeasureMan { get; set; }
    }

    public class VerifyDeviceDto
    {
        public Guid DeviceGuid { get; set; }
        public string Account { get; set; }
        public string Password { get; set; }
        public string EncryptedDogNumber { get; set; }
        public string EncryptedDogType { get; set; }
    }

    /// <summary>
    /// 设备项目
    /// </summary>
    public class DeviceProjectDto
    {
        public Guid DeviceGuid { get; set; }
        public Guid ProjectId { get; set; }
        public string ProjectName { get; set; }
    }

    public class DeviceAssignDto
    {
        public Guid userId { get; set; }
    }
}